package com.wh.stock.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wh.stock.pojo.Stock;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

/**
* 后端Service接口；
*/
@Mapper
@Repository
public interface StockMapper extends BaseMapper<Stock> {

    /**
     * 分页：查询当前页数据
     * @param page 分页参数
     * @param queryWrapper 查询条件
     * @return
     */
    List<Stock> findByPage(@Param("page") IPage<Stock> page,@Param("ew") QueryWrapper<Stock> queryWrapper);
    Stock findProductBystock (Integer stockId);

    void updateStock(Integer id, Integer stock);

    /**
     * 库存处理(发货成功)
     * @param productNumber
     */
    void stockprocessing(Long productNumber,Long StockId);

    /**
     * 库存处理，订单取消，库存回增
     * @param productNumber
     * @param StockId
     */
    void stockprocessingAdd(Long productNumber, Long StockId);

    void updateProduct(Integer stockId, String productName, String picture, BigDecimal price, Integer classifyId);
}
